package com.pen.interfece.controller.admin;

import com.pen.interfece.pojo.PageResult;
import com.pen.interfece.pojo.Result;
import com.pen.interfece.pojo.dto.AdminPageQueryDTO;
import com.pen.interfece.pojo.dto.DisciplinaryPageQueryDTO;
import com.pen.interfece.pojo.dto.StudentDTO;
import com.pen.interfece.pojo.entity.Disciplinary;
import com.pen.interfece.service.DisciplinarySerivice;
import com.pen.interfece.service.StudentSerivice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/dis")
@Slf4j
public class DisciplinaryController {
    @Autowired
    private DisciplinarySerivice disciplinarySerivice;
    //查询违纪类型
    @GetMapping("/page")
    public Result<PageResult> page(@RequestBody DisciplinaryPageQueryDTO disciplinaryPageQueryDTO){
        log.info("违纪分页查询：参数为：{}",disciplinaryPageQueryDTO);
        PageResult pageResult=disciplinarySerivice.pageQuery(disciplinaryPageQueryDTO);
        return Result.success(pageResult);
    }

    //新增违纪类型(不用了）
    @PostMapping("/add")//此时的id是宿舍id
    public Result save(@RequestBody Disciplinary disciplinary){
        log.info("新增违纪类型：{}",disciplinary);
        disciplinarySerivice.save(disciplinary);
        return Result.success("增加成功");
    }

    //删除违纪
    @DeleteMapping
    public Result delete(@RequestParam List<Long> ids)
    {
        log.info("违纪类型批量删除：{}",ids);
        disciplinarySerivice.deleteBatch(ids);
        return Result.success("删除成功");
    }
    //修改违纪
    @PutMapping
    public Result update(@RequestBody Disciplinary disciplinary){
        log.info("违纪修改：{}",disciplinary);
        disciplinarySerivice.update(disciplinary);
        return Result.success("修改成功");
    }
}
